package com.huawei;

import java.util.ArrayList;
import java.util.Scanner;

/**
 * Created by Z-hong on 2024/7/4.
 */

public class HJ22 {
    public static void main(String[] args) {
        Scanner in =new Scanner(System.in);
        ArrayList<Integer> arr = new ArrayList<Integer>();
        while(in.hasNext()){
            int n = in.nextInt();
            if(n==0) break;
            arr.add(n);
        }
        for (Integer i : arr) {
            int count = 0;
            while(i>0){
                int sum = i/3;
                int yushu= i%3;
                count+=sum;
                if(sum == 0){
                    if(yushu == 2){
                        count++;
                    }
                    break;
                }
                i=sum+yushu;
            }
            System.out.println(count);
        }

    }
}
